﻿<UserControl x:Class="SimpleImageApplication.ThumbnailCollectionView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:dragdrop="clr-namespace:DragDropLibrary;assembly=DragAndDrop"             
             xmlns:local="clr-namespace:SimpleImageApplication"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <ListBox Grid.Row="0" Name="lstItems" SelectionMode="Extended" HorizontalAlignment="Stretch" Focusable="False" VerticalAlignment="Stretch"
                 ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Visible" Padding="0,0,0,0"                      
                 BorderBrush="Black" BorderThickness="2"
                 dragdrop:DragAndDrop.RegisterDragSourceName="ImageCollectionView" 
                 dragdrop:DragAndDrop.RegisterDropTargetName="ThumbnailListView"
                 dragdrop:DragAndDrop.DropMethodName="DropOntoImageCollectionView"    
                 dragdrop:DragAndDrop.DropEnabled="True"                                                                          
                 ScrollViewer.CanContentScroll="True"                                                    
             >
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <local:VirtualizingTilePanel Margin="0" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Visible" x:Name="itemsPanel"
                                                 Loaded="itemsPanel_Loaded" />
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid Tag="{Binding}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Cursor="Arrow" Margin="0">
                        <local:ImageViewer x:Name="thumbView" IImageSourceProvider="{Binding}" 
                                                 BorderThickness="1" Padding="0" Margin="1" BorderBrush="Black" Foreground="Black"                                                 
                                                 Width="{Binding Mode=OneWay, Path=ActualWidth}"
                                                 Height="{Binding Mode=OneWay, Path=ActualHeight}"
                                                 Tag="{Binding}" />                     
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

    </Grid>
</UserControl>
